/*
    Copyright © 2010  Ahti Legonkov

    This file is part of j+-.

    j+- is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    j+- is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package cx.ath.skyflyer.javapm;

import joptsimple.OptionParser;
import joptsimple.OptionSet;

/**
 *
 * @author Ahti Legonkov
 */
public class CommandLine {
    private static final String NOLOGO = "nologo";
    private static final String HELP = "help";
    private static final String VERSION = "version";
    private static final String DEBUG = "debug";
    private static final String DIAG = "diag";
    private static final String PARSEONLY = "parseonly";
    private static final String INFILE = "infile";
    private static final String OUTFILE = "outfile";
    private static final String INDIR = "indir";
    private static final String OUTDIR = "outdir";

    public CommandLine(String[] args) {
        OptionParser op = new OptionParser();
        op.accepts(NOLOGO);
        op.accepts(HELP);
        op.accepts(VERSION);
        op.accepts(DEBUG);
        op.accepts(DIAG).withRequiredArg();
        op.accepts(PARSEONLY);
        op.accepts(INFILE).withRequiredArg();
        op.accepts(OUTFILE).withRequiredArg();
        op.accepts(INDIR).withRequiredArg();
        op.accepts(OUTDIR).withRequiredArg();

        this.options = op.parse(args);
    }

    public boolean hasDebug() {
        return options.has(DEBUG);
    }

    public boolean hasDiag() {
        return options.has(DIAG);
    }

    public boolean hasNologo() {
        return options.has(NOLOGO);
    }

    public boolean hasHelp() {
        return options.has(HELP);
    }

    public boolean hasInFile() {
        return options.has(INFILE);
    }

    public boolean hasOutFile() {
        return options.has(OUTFILE);
    }

    public boolean hasInDir() {
        return options.has(INDIR);
    }
    
    public boolean hasOutDir() {
        return options.has(OUTDIR);
    }
    
    public boolean hasVersion() {
        return options.has(VERSION);
    }

    public boolean isParseOnly() {
        return options.has(PARSEONLY);
    }
    
    public String diag() {
        assert(hasDiag());
        return (String)options.valueOf(DIAG);
    }
    
    public String inputFileName() {
        assert(hasInFile());
        return (String)options.valueOf(INFILE);
    }

    public String outputFileName() {
        assert(hasOutFile());
        return (String)options.valueOf(OUTFILE);
    }

    public String inputDir() {
        assert(hasInDir());
        return (String)options.valueOf(INDIR);
    }

    public String outputDir() {
        assert(hasOutDir());
        return (String)options.valueOf(OUTDIR);
    }

    private OptionSet options;
}
